# Maintainer: Biswapriyo Nath <nathbappai@gmail.com>

_realname=pyarrow
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=20.0.0
pkgrel=1
pkgdesc="Columnar in-memory analytics layer for big data — Python module (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://arrow.apache.org/"
msys2_repository_url="https://github.com/apache/arrow"
msys2_references=(
  'archlinux: arrow'
  "cpe: cpe:/a:apache:arrow"
  'purl: pkg:pypi/pyarrow'
)
license=('spdx:Apache-2.0')
depends=(
  "${MINGW_PACKAGE_PREFIX}-arrow"
  "${MINGW_PACKAGE_PREFIX}-python"
  "${MINGW_PACKAGE_PREFIX}-python-numpy"
)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-cc"
  "${MINGW_PACKAGE_PREFIX}-clang"
  "${MINGW_PACKAGE_PREFIX}-cmake"
  "${MINGW_PACKAGE_PREFIX}-cython"
  "${MINGW_PACKAGE_PREFIX}-ninja"
  "${MINGW_PACKAGE_PREFIX}-python-build"
  "${MINGW_PACKAGE_PREFIX}-python-installer"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools"
  "${MINGW_PACKAGE_PREFIX}-python-setuptools-scm"
)
options=('!strip')
source=("https://www.apache.org/dyn/closer.lua?action=download&filename=arrow/arrow-${pkgver}/apache-arrow-${pkgver}.tar.gz"{,.asc})
sha256sums=('89efbbf852f5a1f79e9c99ab4c217e2eb7f991837c005cba2d4a2fbd35fad212'
            'SKIP')
validpgpkeys=(
  'AF6AADA4C9835B75973FF5DA275C532289DD0F4A' # Raúl Cumplido Domínguez (CODE SIGNING KEY) <raulcd@apache.org>
  '08D3564B7C6A9CAFBFF6A66791D18FCF079F8007' # Kouhei Sutou <kou@clear-code.com>
)

build() {
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}

  cd "apache-arrow-${pkgver}/python"

  PYARROW_CMAKE_GENERATOR="Ninja" \
  PYARROW_CMAKE_OPTIONS="-DARROW_SIMD_LEVEL=NONE -DARROW_RUNTIME_SIMD_LEVEL=MAX" \
  PYARROW_WITH_DATASET=1 \
  PYARROW_WITH_FLIGHT=1 \
  PYARROW_WITH_HDFS=1 \
  PYARROW_WITH_PARQUET=1 \
  PYARROW_WITH_PARQUET_ENCRYPTION=1 \
  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "apache-arrow-${pkgver}/python"

  MSYS2_ARG_CONV_EXCL="--prefix=" \
    ${MINGW_PREFIX}/bin/python -m installer --prefix=${MINGW_PREFIX} \
    --destdir="${pkgdir}" dist/*.whl
}
